IndiaBIX
IndiaBIX
Start typing & press "Enter" or "ESC" to close
  • Home
  • Jobs
  • Results
  • Current Affairs
  • GK
  • Online Test
  • HR Interview
  • BLOG

Control Instructions - General Questions (2)

  • Home
  • Computer Science & Engineering
  • C# Programming Questions and Answers
  • Control Instructions - General Questions
9. 

Which of the following statements are correct?

1 A switch statement can act on numerical as well as Boolean types.

2 A switch statement can act on characters, strings and enumerations types.

3 We cannot declare variables within a case statement if it is not enclosed by { }.

4 The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects.

5 All of the expressions of the for statement are not optional.

A. 1, 2
B. 2, 3
C. 3, 5
D. 4, 5
E. None of these

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

10. 

Which of the following statements are correct about the C#.NET code snippet given below?

if (age > 18 && no < 11)
a = 25;

1 The condition no < 11 will be evaluated only if age > 18 evaluates to True.

2 The statement a = 25 will get executed if any one condition is True.

3 The condition no < 11 will be evaluated only if age > 18 evaluates to False.

4 The statement a = 25 will get executed if both the conditions are True.

5 && is known as a short circuiting logical operator.

A. 1, 3
B. 2, 5
C. 1, 4, 5
D. 3, 4, 5
E. None of these

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

11. 

The C#.NET code snippet given below generates ____ numbers series as output?

int i = 1, j = 1, val;
while (i < 25)
{
Console.Write(j + " ");
val = i + j;
j = i;
i = val;
}

A. Prime
B. Fibonacci
C. Palindrome
D. Odd
E. Even

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

12. 

Which of the following can be used to terminate a while loop and transfer control outside the loop?

1 exit while

2 continue

3 exit statement

4 break

5 goto

 

A. 1, 3
B. 2, 4
C. 3, 5
D. 4, 5
E. None of these

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

13. 

Which of the following code snippets are the correct way to determine whether a is Odd or Even?

1 int a;
String res;
if (a % 2 == 0)
res = "Even";
else
res = "Odd";

2 int a;
String res;
if (a Mod 2 == 0)
res = "Even";
else
res = "Odd";

3 int a;
Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd");

4 int a;
String res;
a % 2 == 0 ? res = "Even" : res = "Odd";
Console.WriteLine(res);

 

A. 1, 3
B. 1 Only
C. 2, 3
D. 4 Only
E. None of these

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

14. 

Which of the following is the incorrect form of Decision Control instruction?

A. if (Condition1) {// Some statement}
B. if (Condition1) {// Some statement} else {// Some statement}
C. if (Condition1) {// Some statement} else {// Some statement} else if ( Condition2){//Some statement}
D. if ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else {// Some statement}
E. if ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else if ( Condition3 ) {// Some statement} else {// Some statement}

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

15. 

What will be the output of the C#.NET code snippet given below?

char ch = Convert.ToChar ('a' | 'b' | 'c');
switch (ch)
{
case 'A':
case 'a':
Console.WriteLine ("case A | case a");
break;

case 'B':
case 'b':
Console.WriteLine ("case B | case b");
break;

case 'C':
case 'c':
case 'D':
case 'd':
Console.WriteLine ("case D | case d");
break;
}

A. case A | case a
B. case B | case b
C. case D | case d
D. Compile Error
E. No output

Answer: Option

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

16. 

What will be the output of the C#.NET code snippet given below?

int val;
for (val = -5; val <= 5; val++)
{
switch (val)
{
case 0:
Console.Write ("India");
break;
}

if (val > 0)
Console.Write ("B");
else if (val < 0)
Console.Write ("X");
}

A. XXXXXIndia
B. IndiaBBBBB
C. XXXXXIndiaBBBBB
D. BBBBBIndiaXXXXX
E. Zero

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Discuss Workspace Report

  • 1
  • 2
  • 3

Questions & Answers

Aptitude Chemical Engineering Civil Engineering Computer Science & Engineering Current Affairs Data Interpretation Electrical & Electronics Engineering Electronics & Communication Engineering General Knowledge Logical Reasoning Mechanical Engineering Non Verbal Reasoning Verbal Ability Verbal Reasoning

Interviews

HR Interview

Jobs

Sarkari Jobs

Results

Rojgar ResultSarkari Result

Admission

Admission 2023

Admit Card

Admit Card 2023

Answer Key

Answer Key 2023
copyright
Privacy Policy
© 2026 IndiaBIX. All Rights Reserved.

Report